home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / bob_espo.swf / scripts / __Packages / Algae.as < prev    next >
Encoding:
Text File  |  2013-04-24  |  2.6 KB  |  104 lines

  1. class Algae extends State
  2. {
  3.    var mcRef;
  4.    var nCountDown;
  5.    var sState;
  6.    static var sLINKAGE_NAME = "mcAlgae";
  7.    var sSTATE_IDLE = "Idle";
  8.    var sSTATE_CATCHING = "Catching";
  9.    var sSTATE_CAUGHT = "Caught";
  10.    var sSTATE_FALLING = "Falling";
  11.    var sSTATE_FALLEN = "Fallen";
  12.    var sSTATE_RETURN = "Return";
  13.    var nMAX_COUNTDOWN = 200;
  14.    static var nCOUNTER = 0;
  15.    static var nMIN_DEPTH = 200012;
  16.    static var nSUBSTRACT_DEPTH = 200000;
  17.    static var nDEPTH_FACTOR = 25;
  18.    static var nMIN_WAIT_TIME = 50;
  19.    static var nMAX_WAIT_TIME = 250;
  20.    function Algae(_nX, _nY)
  21.    {
  22.       super(CTRLGame.getRef().mcRef.attachMovie(Algae.sLINKAGE_NAME,Algae.sLINKAGE_NAME + Algae.nCOUNTER,this.calculateDepth(_nY,CTRLGame.nALGAE_ADD + Algae.nCOUNTER)));
  23.       Algae.nCOUNTER = Algae.nCOUNTER + 1;
  24.       this.mcRef._x = _nX;
  25.       this.mcRef._y = _nY;
  26.       this.setIdleState();
  27.       this.nCountDown = 0;
  28.       if(Controller.getRef().isPaused())
  29.       {
  30.          this.doPause();
  31.       }
  32.    }
  33.    function cleanUp()
  34.    {
  35.       super.cleanUp();
  36.       this.mcRef.swapDepths(7777);
  37.       this.mcRef.removeMovieClip();
  38.    }
  39.    function catchBus()
  40.    {
  41.       this.setState(this.sSTATE_CATCHING);
  42.    }
  43.    function setInactive()
  44.    {
  45.       this.setState(this.sSTATE_FALLING);
  46.       this.nCountDown = this.nMAX_COUNTDOWN;
  47.       this.mcRef.swapDepths(this.mcRef.getDepth() - Algae.nSUBSTRACT_DEPTH);
  48.    }
  49.    function isInactive()
  50.    {
  51.       return this.sState != this.sSTATE_IDLE;
  52.    }
  53.    function setIdleState()
  54.    {
  55.       var _loc2_ = Math.round(Math.random() * 42) + 1;
  56.       this.setState(this.sSTATE_IDLE);
  57.       this.mcRef.mcState.gotoAndPlay(_loc2_);
  58.    }
  59.    function calculateDepth(_nY, _nAdd)
  60.    {
  61.       var _loc4_ = Math.round(_nY) * Algae.nDEPTH_FACTOR + Algae.nMIN_DEPTH + _nAdd;
  62.       return _loc4_;
  63.    }
  64.    function Idle()
  65.    {
  66.    }
  67.    function Catching()
  68.    {
  69.       if(this.stateFinished())
  70.       {
  71.          this.setState(this.sSTATE_CAUGHT);
  72.       }
  73.    }
  74.    function Caught()
  75.    {
  76.    }
  77.    function Falling()
  78.    {
  79.       if(this.stateFinished())
  80.       {
  81.          this.setState(this.sSTATE_FALLEN);
  82.       }
  83.    }
  84.    function Fallen()
  85.    {
  86.       if(!Controller.getRef().isPaused() && !CTRLGame.getRef().Screen.isInMiniGame())
  87.       {
  88.          this.nCountDown = this.nCountDown - 1;
  89.          if(this.nCountDown <= 0)
  90.          {
  91.             this.setState(this.sSTATE_RETURN);
  92.          }
  93.       }
  94.    }
  95.    function Return()
  96.    {
  97.       if(this.stateFinished())
  98.       {
  99.          this.setIdleState();
  100.          this.mcRef.swapDepths(this.mcRef.getDepth() + Algae.nSUBSTRACT_DEPTH);
  101.       }
  102.    }
  103. }
  104.